package com.dosof.optimuserp.dao;

import java.sql.SQLException;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dosof.optimuserp.model.Usuario;

@Component
public class UsuarioDao {

    @PersistenceContext
    private EntityManager entityManager;

    @Transactional
    public void save(Usuario object) throws SQLException {
        entityManager.persist(object);
    }

    @SuppressWarnings("unchecked")
	public List<Usuario> list() {
        return (List<Usuario>)entityManager.createQuery("select o from Usuario o")
                .getResultList();
    }
}
